<template>
  <el-dialog
    title="录用质检"
    :visible.sync="editDialogShow"
    :destroy-on-close="true"
    :append-to-body="true"
    width="45%"
    @close="handleClose"
    class="edit-main"
  >
    <el-form ref="formData" :model="formData" :rules="rules" label-width="80px">
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-form-item label="客户姓名" prop="questionText">
            <el-input
              type="input"
              placeholder="请输入内容"
              v-model="formData.questionText"
              maxlength="200"
              show-word-limit
            />
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label="客户号码" prop="questionText">
            <el-input
              type="input"
              placeholder="请输入内容"
              v-model="formData.questionText"
              maxlength="200"
              show-word-limit
            />
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label="客户状态" prop="questionText">
            <el-select
              v-model="formData.questionText"
              filterable
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="item in voiceTypeList"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label="品牌" prop="questionText">
            <el-input
              type="input"
              placeholder="请输入内容"
              v-model="formData.questionText"
              maxlength="200"
              show-word-limit
            />
          </el-form-item>
        </el-col>

        <el-col :span="1.5">
          <el-form-item label="车系" prop="questionText">
            <el-input
              type="input"
              placeholder="请输入内容"
              v-model="formData.questionText"
              maxlength="200"
              show-word-limit
            />
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label="省份" prop="questionText">
            <el-input
              type="input"
              placeholder="请输入内容"
              v-model="formData.questionText"
              maxlength="200"
              show-word-limit
            />
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label="城市" prop="questionText">
            <el-input
              type="input"
              placeholder="请输入内容"
              v-model="formData.questionText"
              maxlength="200"
              show-word-limit
            />
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label="具体区县" prop="questionText">
            <el-input
              type="input"
              placeholder="请输入内容"
              v-model="formData.questionText"
              maxlength="200"
              show-word-limit
            />
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label="上牌时间" prop="questionText">
            <el-date-picker
              v-model="formData.questionText"
              type="date"
              placeholder="选择日期"
            >
            </el-date-picker>
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label="公里数" prop="questionText">
            <el-input
              type="input"
              placeholder="请输入内容"
              v-model="formData.questionText"
              maxlength="200"
              show-word-limit
            />
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label="是否可以正常过户" prop="questionText">
            <el-select
              v-model="formData.questionText"
              filterable
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="item in voiceTypeList"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label="车辆来源" prop="questionText">
            <el-select
              v-model="formData.questionText"
              filterable
              placeholder="请选择"
              clearable
            >
              <el-option
                v-for="item in voiceTypeList"
                :key="item.dictValue"
                :label="item.dictLabel"
                :value="item.dictValue"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="1.5">
          <el-form-item label="预约时间（看车时间）" prop="questionText">
            <el-input
              type="input"
              placeholder="请输入内容"
              v-model="formData.questionText"
              maxlength="200"
              show-word-limit
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="onSubmit">提 交</el-button>
      <el-button  @click="onSubmit">取消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { updateMsg } from "@/api/customerService/session";

export default {
  name: "messageListDialog",
  props: {
    editShow: {
      type: Boolean,
      default: false,
    },
    questionText: {
      type: String,
      default: "",
    },
    id: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      loading: false,
      tableData: [], //表格数据
      pagination: {
        pageNum: 1,
        pageSize: 10,
      },
      formData: {
        questionText: "",
      },
      voiceTypeList: [],
      rules: {
        questionText: [
          { required: true, message: "内容不能为空", trigger: "blur" },
        ],
      },
      total: 0,
      editDialogShow: false,
    };
  },

  watch: {
    editShow: {
      handler(val) {
        if (val) {
          this.editDialogShow = val;
        }
      },
      immediate: true,
    },
    questionText: {
      handler(val) {
        if (val) {
          this.formData.questionText = val;
        }
      },
      immediate: true,
    },
  },
  methods: {
    // 保存
    onSubmit() {
      this.$refs["formData"].validate(async (valid) => {
        if (valid) {
          const params = {
            id: this.id,
            questionText: this.formData.questionText,
          };
          const { code } = await updateMsg(params);
          if (code === 200) {
            this.handleClose();
          }
        }
      });
    },

    handleClose() {
      this.editDialogShow = false;
      this.formData.questionText = "";
      this.pagination = {
        pageNum: 1,
        pageSize: 10,
      };
      this.total = 0;
      this.tableData = [];
      this.$emit("onCloseEditDialog");
    },
  },
};
</script>

<style lang="scss" scoped>
.edit-main {
  ::v-deep .el-textarea__inner {
    height: 150px;
  }
}
</style>
